import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 回收问题选项信息 */
export interface Question {
  questionTitle: string // 问题标题
  categoryId: number // 适用品类ID(为空表示通用)
  questionType: number // 问题类型(1-单选,2-多选,3-文本)
  options: string // 选项列表(JSON格式)
  status: number // 状态(0-禁用,1-启用)
  sort: number // 排序值
  imgRul?: string // 图片url
}

// 回收问题选项 API
export const QuestionApi = {
  // 查询回收问题选项分页
  getQuestionPage: async (params: any) => {
    return await request.get({ url: `/recycling/question/page`, params })
  },

  // 查询回收问题选项详情
  getQuestion: async (id: number) => {
    return await request.get({ url: `/recycling/question/get?id=` + id })
  },

  // 新增回收问题选项
  createQuestion: async (data: Question) => {
    return await request.post({ url: `/recycling/question/create`, data })
  },

  // 修改回收问题选项
  updateQuestion: async (data: Question) => {
    return await request.put({ url: `/recycling/question/update`, data })
  },

  // 删除回收问题选项
  deleteQuestion: async (id: number) => {
    return await request.delete({ url: `/recycling/question/delete?id=` + id })
  },

  /** 批量删除回收问题选项 */
  deleteQuestionList: async (ids: number[]) => {
    return await request.delete({ url: `/recycling/question/delete-list?ids=${ids.join(',')}` })
  },

  // 导出回收问题选项 Excel
  exportQuestion: async (params) => {
    return await request.download({ url: `/recycling/question/export-excel`, params })
  }
}
